package com.lhd._05weibo.config;

import com.lhd._05weibo.interceptors.MyInterCeptor;
import com.lhd._05weibo.interceptors.UserLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author lhd
 * @date 2024/4/28
 * @apiNote
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {
//    @Override
//    public void addInterceptors	(InterceptorRegistry registry) {
//        //拦截所有请求
////        registry.addInterceptor(new MyInterCeptor());
//
//        registry.addInterceptor(new MyInterCeptor())
//                .addPathPatterns("/v1/weibo/**").excludePathPatterns("/v1/weibo/selectById");
//
//    }

    public void addInterceptors	(InterceptorRegistry registry) {
        registry.addInterceptor(new UserLoginInterceptor())
                .addPathPatterns("/v1/comment/insert", "/v1/weibo/insert");
    }
}
